<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>修改广告位</title>
<link href="${rc.getContextPath()}/resources/css/common.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="${rc.getContextPath()}/resources/js/jquery.js"></script>
<script type="text/javascript" src="${rc.getContextPath()}/resources/js/common.js"></script>
<script type="text/javascript" src="${rc.getContextPath()}/resources/js/jquery.validate.js"></script>
<script type="text/javascript" src="${rc.getContextPath()}/resources/js/messages_cn.js"></script>
<script type="text/javascript" src="${rc.getContextPath()}/resources/js/input.js"></script>
<script type="text/javascript" src="${base}/js/ajaxupload.js"></script>
 <!-- 引入弹出JS begin -->
<script type="text/javascript" src="${rc.getContextPath()}/js/lhgdialog/lhgdialog.min.js?self=true"></script>
<!-- 引入弹出JS end -->
<script type="text/javascript">

$().ready(function() {
	var $inputForm = $("#inputForm");
	initUploadButton("advImage");
	 
});

function updateadv(){
	var form1 = $("#inputForm");
	form1.submit();
}
function back(){
	$.dialog.tips("返回中,请稍等...",600,"loading.gif");
	window.location.href='list.html ';
}

 

function initUploadButton(buttonId){
	var button = $("#"+buttonId);
	var exts = "jpg|png|gif",paths = "|";
	new AjaxUpload(button,
	{   
			action: '${base}/content/admin/uploadImage.html',   
			name: 'uploadFile',
		onSubmit : function(file, ext)
		{     
       		if ( !RegExp( "\.(?:" + exts + ")$$", "i" ).test(file) ) 
       		{
       			$.dialog.alert("只能上传以下类型：" + exts).zindex();
				return false;
			}          		         
		 	},   
		 	onComplete: function(file, response,statusText)
		 	{   
			var response = jQuery.parseJSON(response);
		 		//eval("var response = " + response + ";");
		 		if(response.status=="error")
			{
		 			$.dialog.alert("上传失败！") ;
			}
			else 
			{
				$("#"+buttonId+"Path").val(response.path);
				$.dialog.alert("上传成功！") ;
			}
		}   
	}); 
}
//预览图片
function imgShow(name) {
	if($("#"+name).val()=="") {
		$.dialog.alert("请先选择上传图片");
		return;
	}
	var path = $("#"+name).val();
	var url = '<img src="'+path+'"  />';
	$.dialog({
		lock: true,
		width:'700px',
		height:'315px',
		content: url,
		cancelVal: '关闭',
		autoSize:true,
	    cancel: function(){ //请求成功后处理函数。
	    	
		}
	});

}

function clearImage(id){
	
	$("#"+id).val("");
}










</script>
</head>

 

<body>




<div class="path">
		  <a href="#"> 修改广告位</a>
	</div>
	
	<form id="inputForm" action="${base!}/adv1/admin/update.html" method="post">
 
		<input type="hidden" id="id" name="id" value="${adv.id}"/>
 
		<!-- 基本功能begin -->
		<table class="input tabContent">
			 
			<tr>
				<th>
					banner图:
				</th>
				<td >
				<input type ="text" id="advImagePath" name="url" value="${adv.url!}"   readonly="readonly"  /><br />
					
					<input id="advImage"  class="button"  type="button" value="上传" />
					<input id="clearadvImage"  class="button" onclick="clearImage('advImagePath')" type="button" value="清除" />
					<input type="button"  class="button" value="预览" onclick="imgShow('advImagePath')"/>
					 
					<br />上传类型：*.png;*.bmp;*.jpeg;*.jpg
				</td>
				
			</tr>
			<tr>
				<th>
					 外联地址:
				</th>
				<td >
					 	<input   type="text"   name= "link" value="${adv.link!''}"/>(必须以http://开头)
				</td>
				
			</tr>

 
		</table>
		
		<table class="input">
			<colgroup>
				<col  width="15%"/>
				<col  width="35%"/>
				<col  width="15%"/>
				<col  width="35%"/>
			</colgroup>
			<tr>
				<td>

				</td>
				<td colspan="3">
					<input type="button" class="button" value="保存"  onclick="updateadv()"/>
					<input type="button" id="backButton" class="button" value="返回" onclick="javascript:back()" />
				</td>
			</tr>
		</table> 
	</form>
</body>
</html>